#include "Space.h"

Space::Space()
{
	Clear();
}
//Cleans up the m_cszpWalls it holds
Space::~Space()
{
	Clear();
}

const void Space::Init(int const & WorldX,int const & WorldY,eSpaceType const & SpaceType,Space* ConnectedTo)
{
	//Tells the space before that this is the next space
	ConnectedTo->m_clpNextConnection = this;
	//Tells this space about the space before
	m_clpPrevConnection = ConnectedTo;
	//Tells this space that there is no next space
	m_clpNextConnection = NULL;
	//Tells it if it is a geyser or minecart
	m_eTypeSpace = SpaceType;

	LastSpace = false;
}

const void Space::Clear()
{
	m_eTypeSpace = BLANK;
	m_clpPrevConnection = NULL;
	m_clpNextConnection = NULL;
	m_clpNextConnectionSpecial = NULL;
	SetMineralType(TILE_NULL);
}

const void Space::CreateSpace(int const & x,int const & y,eTileType const & Mat,Space* ConnectedTo)
{
	m_vPosition.x = (float)x;
	m_vPosition.y = (float)y;
	m_vPosition.z = 0.0f;
	m_bDrawing = true;
	LastSpace = false;
	SetTypeSpace(NORMAL);
	SetMineralType(Mat);
	m_clpPrevConnection = ConnectedTo;
}

const void Space::SetMineralType(eTileType const & MatType)
{
	textureIndex = m_eMineral = MatType;
}

const void Space::SetTypeSpace(eSpaceType const & SpaceType)
{
	m_eTypeSpace = SpaceType;
}

const void Space::SetLastSpace()
{
	LastSpace = true;
}

const void Space::MakeIntoSpecial(Space* const SpecialConnection,eSpaceType const & SpaceType)
{
	m_eTypeSpace = SpaceType;
	m_clpNextConnectionSpecial = SpecialConnection;
}

//TODO: Finsih these three functions
Space* Space::MoveForward()
{
	return m_clpNextConnection;
}

Space* Space::MoveBackward()
{
	return m_clpPrevConnection;
}

Space* Space::LandOn()
{
	Space* MoveTo = this;
	//if it isn't a normal space the next space is a chute or ladder space
	switch(m_eTypeSpace)
	{
	case MINECART_START:
	case GEYSER_START:
		MoveTo = Jump();
	}
	return MoveTo;
}

Space* Space::Jump()
{
	return m_clpNextConnectionSpecial;
}

const void Space::Update() const
{
	//Each Space Does not need to update
	return;
}